package yxy.game.pm2.active.handle;

import yxy.game.pm2.bean.Currency;
import yxy.game.pm2.bean.mq.CCReason;
import yxy.game.pm2.module.CurrencyHandle;
import yxy.game.pm2.module.battle.ISettlement;

import java.util.ArrayList;
import java.util.Collection;

/** 爬塔的战斗结算 */
public class SettlementTimeChallenge implements ISettlement {
	// bean===========================================================================

	private String playerCode;
	private int id;
	private ArrayList<Currency> rewards = new ArrayList<>();

	public String getPlayerCode() {
		return playerCode;
	}
	public void setPlayerCode(String playerCode) {
		this.playerCode = playerCode;
	}
	public int getId() {
		return id;
	}
	public void setId(int id) {
		this.id = id;
	}
	public ArrayList<Currency> getRewards() {
		return rewards;
	}
	public void setRewards(ArrayList<Currency> rewards) {
		this.rewards = rewards;
	}

	// func===========================================================================

	@Override
	public void settle() {
		new CurrencyHandle().addCurrency(playerCode, CCReason.活动_限时挑战, getRewards());
	}

	@Override
	public Collection<Currency> reward() {
		return getRewards();
	}

	static public SettlementTimeChallenge create(String playerCode, int id) {
		SettlementTimeChallenge settlement = new SettlementTimeChallenge();
		try {
			
			settlement.setPlayerCode(playerCode);
			settlement.setId(id);
			settlement.setRewards(new ArrayList<>(Act_TimeChallengeHandle.getRewards(id, playerCode)));

			return settlement;
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		}
	}

}
